import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * Clase principal para ejecutar el programa de enlaces
 * @author Francisco
 *
 */
public class Enlaces {

	/**
	 * Metodo de entrada
	 * @param args Parametros del programa
	 */
	public static void main(String[] args) {

		// Se busca archivo txt
		java.io.BufferedReader reader = null;
		
		try
		{
			
			reader = new BufferedReader(new FileReader("Enlaces 3 MCC 2013.txt"));
			
			StringBuilder stringFinal = new StringBuilder();
			
			//Manager
			FileManager fileManager = new FileManager();
			
			while (reader.ready()){
				String line = reader.readLine();
				
				try
				{
				
					String result = fileManager.processLine(line);
					
					if (!result.equals("")){
						stringFinal.append(result + "\n");
					}
				}catch(Exception ex){
					System.err.println(ex.getMessage());
				}
			}
			
			reader.close();
			
			//Salida
			System.out.println(stringFinal);
		}
		catch(FileNotFoundException ex){
			System.err.println(ex.getMessage());
		}
		catch(IOException ex){
			System.err.println(ex.getMessage());
		}
		catch(Exception ex){
			System.err.printf("%s %s",ex.getMessage(),ex.getCause());
		}
		finally{
					
		}
	}
}
